package com.itheima.d2_genericity_limit;

import java.util.ArrayList;

/**
 * ?在泛型中做通配符，但是通常要限定其范围
 * ？extends Car:?必须是Car或者其子类，泛型上限
 * ？super Car:?必须是Car或者其父类，泛型下限
 */
public class demo {
    public static void main(String[] args) {
        ArrayList<BENZ> benzs = new ArrayList<>();
        benzs.add(new BENZ());
        benzs.add(new BENZ());
        benzs.add(new BENZ());
        go(benzs);
        ArrayList<BWM> BWM = new ArrayList<>();
        BWM.add(new BWM());
        BWM.add(new BWM());
        BWM.add(new BWM());
        go(BWM);


    }

    public static void go(ArrayList<?extends car> cars){//ArrayList<BWM>  ArrayList<BENZ>和ArrayList<?Car>不是同一种概念，应该当作整体来看待

    }
}
//super
class car{}

//sub1
class BENZ extends car{}

//sub2
class BWM extends car{}

//other
class Dog {}
